package tt.com.depositmessage.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

import tt.com.common.model.TombDeposit;
import tt.com.common.util.CommonResult;
import tt.com.depositmessage.service.DepositService;
import tt.com.depositmessage.vo.DepositVo;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;


@RestController
@RequestMapping(value = "dep/msg")
public class DepositController {

    @Autowired
    private DepositService service;

    @PostMapping(value = "show/dep")
    public ResponseEntity showDepositMessage(@RequestBody DepositVo vo , HttpServletRequest request){
        CommonResult result = service.showDepositMessage(vo.getI(), vo.getPageUtil());
        return new ResponseEntity(result, HttpStatus.valueOf(result.getStatus()));
    }

    @PostMapping(value = "change/msg")
    public ResponseEntity changeDepositMessage(@RequestBody TombDeposit tombDeposit , HttpServletRequest request){
        CommonResult result = service.changeDepositMessage(tombDeposit);
        return new ResponseEntity(result, HttpStatus.valueOf(result.getStatus()));
    }

    @PostMapping(value = "ref/msg")
    public ResponseEntity RefreshDepositMessage(@RequestBody DepositVo vo , HttpServletRequest request){
        CommonResult result = service.RefreshDepositMessage(vo.getPageUtil());
        return new ResponseEntity(result, HttpStatus.valueOf(result.getStatus()));
    }

    @PostMapping(value = "sel/msg")
    public ResponseEntity selDepositMessage(@RequestBody DepositVo vo , HttpServletRequest request){
        CommonResult result = service.selDepositMessage(vo.getPageUtil(),vo.getTombDeposit());
        return new ResponseEntity(result, HttpStatus.valueOf(result.getStatus()));
    }

    @PostMapping(value = "del/msg")
    public ResponseEntity delDepositMessage(@RequestBody TombDeposit tombDeposit,HttpServletRequest request){
        CommonResult result = service.delDepositMessage(tombDeposit);
        return new ResponseEntity(result, HttpStatus.valueOf(result.getStatus()));
    }

    @PostMapping(value = "ins/msg")
    public ResponseEntity insertDepositMessage(@RequestBody DepositVo vo,HttpServletRequest request){
        CommonResult result = service.insertDepositMessage(vo.getI(),vo.getTombDeposit());
        return new ResponseEntity(result, HttpStatus.valueOf(result.getStatus()));
    }

    @PostMapping(value = "up/add")
    public ResponseEntity updateAddDeposit(@RequestBody DepositVo vo,HttpServletRequest request){
        CommonResult result = service.updateAddDeposit(vo.getDeadId(),vo.getTombDeposit());
        return new ResponseEntity(result, HttpStatus.valueOf(result.getStatus()));
    }

    @GetMapping(value = "show/tomb")
    public ResponseEntity showTombLand(HttpServletRequest request){
        CommonResult result = service.showTombLand();
        return new ResponseEntity(result, HttpStatus.valueOf(result.getStatus()));
    }

    @PostMapping(value = "renew/dep")
    public ResponseEntity renewDeposit(@RequestBody DepositVo vo,HttpServletResponse response){
        CommonResult result = service.renewDeposit(response,vo.getI(),vo.getTombDeposit());
        return new ResponseEntity(result, HttpStatus.valueOf(result.getStatus()));
    }

    @PostMapping(value = "move/bone")
    public ResponseEntity moveBone(@RequestBody DepositVo vo ,HttpServletRequest request){
        CommonResult result = service.moveBone(vo.getAddress(),vo.getTombDeposit());
        return new ResponseEntity(result, HttpStatus.valueOf(result.getStatus()));
    }

    @PostMapping("createPDF1")
    public ResponseEntity createDepositCard(@RequestBody TombDeposit tombDeposit, HttpServletResponse response){
        CommonResult result = service.createDepositCard(response,tombDeposit);
        return new ResponseEntity(result, HttpStatus.valueOf(result.getStatus()));
    }

    @PostMapping("createPDF2")
    public ResponseEntity createPutCertificates(@RequestBody TombDeposit tombDeposit, HttpServletResponse response){
        CommonResult result = service.createPutCertificates(response,tombDeposit);
        return new ResponseEntity(result, HttpStatus.valueOf(result.getStatus()));
    }

    @PostMapping("createPDF3")
    public ResponseEntity createBonbMoveOut(@RequestBody TombDeposit tombDeposit,HttpServletResponse response){
        CommonResult result = service.createBonbMoveOut(response,tombDeposit);
        return new ResponseEntity(result, HttpStatus.valueOf(result.getStatus()));
    }

    @PostMapping("change/land")
    public ResponseEntity changeTombLand(@RequestBody TombDeposit tombDeposit,HttpServletResponse response){
        CommonResult result = service.changeTombLand(tombDeposit);
        return new ResponseEntity(result, HttpStatus.valueOf(result.getStatus()));
    }

}
